package golang

import "gitee.com/allowall-package/goutil/fn"

type MainAbstractFactory interface {
	MainAbstractFactoryOption() string
}

type DetailAbstractFactory interface {
	DetailAbstractFactoryOption() string
}

// 工厂类
type AbstractFactory interface {
	CreateMainAbstractFactory() MainAbstractFactory
	CreateDetailAbstractFactory() DetailAbstractFactory
}

// ---------------分割线---------------

type MainAbstractFactory1 struct{}

func (f *MainAbstractFactory1) MainAbstractFactoryOption() string {
	return "MainAbstractFactory1 MainAbstractFactoryOption"
}

type DetailAbstractFactory1 struct{}

func (f *DetailAbstractFactory1) DetailAbstractFactoryOption() string {
	return "DetailAbstractFactory1 DetailAbstractFactoryOption"
}

// 子工厂类1
type AbstractFactory1 struct{}

func (f *AbstractFactory1) CreateMainAbstractFactory() MainAbstractFactory {
	return &MainAbstractFactory1{}
}

func (f *AbstractFactory1) CreateDetailAbstractFactory() DetailAbstractFactory {
	return &DetailAbstractFactory1{}
}

// ---------------分割线---------------

type MainAbstractFactory2 struct{}

func (*MainAbstractFactory2) MainAbstractFactoryOption() string {
	return "MainAbstractFactory2 MainAbstractFactoryOption"
}

type DetailAbstractFactory2 struct{}

func (*DetailAbstractFactory2) DetailAbstractFactoryOption() string {
	return "DetailAbstractFactory2 DetailAbstractFactoryOption"
}

// 子工厂类2
type AbstractFactory2 struct{}

func (*AbstractFactory2) CreateMainAbstractFactory() MainAbstractFactory {
	return &MainAbstractFactory2{}
}
func (*AbstractFactory2) CreateDetailAbstractFactory() DetailAbstractFactory {
	return &DetailAbstractFactory2{}
}

// ---------------分割线---------------

// 测试方法
func AbstractFactoryTest() {
	var abstract AbstractFactory
	abstract = &AbstractFactory2{}
	fn.Dump(fn.FuncInfo(), abstract.CreateMainAbstractFactory().MainAbstractFactoryOption())
}
